<template>
     <div ref="page">
      <span class="news-text">{{titleName}}</span>  
      <a-divider style="margin-top:10px;margin-bottom:10px;" />
       <div class="search-div">
          <a-input v-model="queryinput" placeholder="请输入项目名称/招标项目编号" style="font-size:12px;"/>
          <a-button type="primary" class="report-search-btn">查询</a-button>
       </div>    
      <div class="unit-table-div">
          <CustomTable
            :onRowClick="onDetail"
            ref="table"
            :showAlert="false"
            :showSelection="false"
            :columns="columns"
            :loading="load"
            @change="onTableChange"
            :dataSource="pageData"
            
          >
            <!-- :scroll="{ y: 400 }" -->
          </CustomTable>
      </div>
    </div>
</template>

<script>
// import moment from "moment";
import emv from "@/views/center/emptyVue.vue";
import api from "@/api/index";
  export default {
    name: "publicinfo",
    props: {
      page: {
        type: String,
        default: '1'
      },
    },
     data(){
      return{
        clientHeight:'',
        screenHeight:'',
        pageName:"tenderInfoPage",
        titleName:"招标信息",
        load: false,
        queryinput: '',
        columns: [
          {
              title: '序号',
              dataIndex: 'xh',
              key: 'xh',
              width:60,
              scopedSlots: { customRender: "xh" }
            },
            {
              title: '项目名称',
              dataIndex: 'xmName',
              key: 'xmName',
              ellipsis: true,
            },
            {
              title: '招标项目编号',
              dataIndex: 'zbxmId',
              key: 'zbxmId',
              ellipsis: true,
            },
            {
              title: '招标人',
              dataIndex: 'zbr',
              key: 'zbr',
              ellipsis: true,
            }, 
            {
              title: '招标代理机构',
              dataIndex: 'zbdljg',
              key: 'zbdljg',
              ellipsis: true,
            },
        ],
        pageData: [
            {
              id: '1',
              xh: '1',
              xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
              zbxmId: 'SXFY2020-027',
              zbr: '李工',
              zbdljg:'方宇工程咨询有限公司',
            },
            {
              id: '2',
              xh: '2',
              xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
              zbxmId: 'SXFY2020-027',
              zbr: '李工',
              zbdljg:'方宇工程咨询有限公司',
            },
            {
              id: '3',
              xh: '3',
              xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
              zbxmId: 'SXFY2020-027',
              zbr: '李工',
              zbdljg:'方宇工程咨询有限公司',
            },
            {
              id: '4',
              xh: '4',
              xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
              zbxmId: 'SXFY2020-027',
              zbr: '李工',
              zbdljg:'方宇工程咨询有限公司',
            },
            {
              id: '5',
              xh: '5',
              xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
              zbxmId: 'SXFY2020-027',
              zbr: '李工',
              zbdljg:'方宇工程咨询有限公司',
            }
         ],
        pageFilter: {
          pageNo: 1,
          pageSize: 10
        }
      }
      
    },
    created() {
      this.queryinput = this.$route.query.searchContent;
    },
    methods: {
      setPage(pageName,titleName){
        this.pageName = pageName;
        this.titleName = titleName;
        if(pageName=='tenderInfoPage'){//招标信息
           this.pageFilter= {
              pageNo: 1,
              pageSize: 10
            }
            this.pageData=[
              {
                id: '1',
                xh: '1',
                xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
                zbxmId: 'SXFY2020-027',
                zbr: '李工',
                zbdljg:'方宇工程咨询有限公司',
              },
              {
                id: '2',
                xh: '2',
                xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
                zbxmId: 'SXFY2020-027',
                zbr: '李工',
                zbdljg:'方宇工程咨询有限公司',
              },
              {
                id: '3',
                xh: '3',
                xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
                zbxmId: 'SXFY2020-027',
                zbr: '李工',
                zbdljg:'方宇工程咨询有限公司',
              },
              {
                id: '4',
                xh: '4',
                xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
                zbxmId: 'SXFY2020-027',
                zbr: '李工',
                zbdljg:'方宇工程咨询有限公司',
              },
              {
                id: '5',
                xh: '5',
                xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
                zbxmId: 'SXFY2020-027',
                zbr: '李工',
                zbdljg:'方宇工程咨询有限公司',
              },
              {
                id: '6',
                xh: '6',
                xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
                zbxmId: 'SXFY2020-027',
                zbr: '李工',
                zbdljg:'方宇工程咨询有限公司',
              },
              {
                id: '7',
                xh: '7',
                xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
                zbxmId: 'SXFY2020-027',
                zbr: '李工',
                zbdljg:'方宇工程咨询有限公司',
              },
              {
                id: '8',
                xh: '8',
                xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
                zbxmId: 'SXFY2020-027',
                zbr: '李工',
                zbdljg:'方宇工程咨询有限公司',
              },
              {
                id: '9',
                xh: '9',
                xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
                zbxmId: 'SXFY2020-027',
                zbr: '李工',
                zbdljg:'方宇工程咨询有限公司',
              },
              {
                id: '10',
                xh: '10',
                xmName: '海口市桂林洋防潮堤加固工程海口市桂林洋防潮堤加固工程',
                zbxmId: 'SXFY2020-027',
                zbr: '李工',
                zbdljg:'方宇工程咨询有限公司',
              }
         ]
        }else if(pageName=='winBidPage'){//中标公示
            this.pageFilter= {
              pageNo: 1,
              pageSize: 10
            }
             this.refreshTable_winBid();
        }

        this.$nextTick(()=>{ // 页面渲染完成后的回调
                  this.getScreenHeight();
                  this.clientHeight = this.$refs.page.offsetHeight+195;
                  if(this.screenHeight>this.clientHeight){
                    emv.$emit("setfootmargintop",this.screenHeight-this.clientHeight);
                  }else{
                    emv.$emit("setfootmargintop",5);
                  }
                });
      },
      onDetail(record){
         let name = '';
         if(this.pageName=='tenderInfoPage'){
            name = 'bidInfoDetail';
         }else{
           name = 'winBidDetail';
         }
          this.$router.push({
              name:name,
              query:{
                type:'detail',
                id:record.xh,
                breadcrumbName:'项目信息'

             }
            });
          
        },
      refreshTable_winBid() {
       this.load = true;
       api .get_winbid_list(this.pageFilter) .then(res => {
          let pageNo = this.pageFilter.pageNo;
          let pageSize = this.pageFilter.pageSize;
          let records = res.rows;
          let total = res.total;
          this.pageData = {
            ...this.pageData,
            pageNo,
            records,
            pageSize,
            total
          };
          this.load = false;
        })
        .catch(err => {});
      },
     onTableChange(pageFilter) {
        this.pageFilter = { ...this.pageFilter, ...pageFilter };
        // if(this.pageName=='tenderInfoPage'){

        // }else if(this.pageName=='winBidPage'){
        //   this.refreshTable_winBid();
        // }
        
    
    },

    getScreenHeight(){
        // 获取浏览器可视区域高度
        this.screenHeight =    document.body.clientHeight ; //`${document.documentElement.clientHeight}` 
        window.onresize = function temp() {
          this.screenHeight = document.body.clientHeight;
        };
      },
   },
   beforeRouteEnter(to, from, next) {
      // 设置下一个路由的 meta
       next(vm=>{
            vm.setPage(to.name, to.meta.title)
            emv.$emit("setMenuKey",to.meta.mkey);
         })
    },
  };
</script>
<style lang="less">
.news-text{
  font-size: 18px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  color: #337BD7;
}

.unit-table-div{
  margin-left: -10px;

}
.search-div{
  width:320px;
  display:flex;
  margin-bottom: 10px;
  .report-search-btn{
    // width: 80px;
    height: 30px;
    background: #337BD7;
    border: 0;
    border-radius: 4px;
    margin-left: 10px;
    margin-top: 1px;
  }
  .ant-btn-primary:hover, .ant-btn-primary:focus {
    color: #fff;
    background-color: #337BD7;
    border-color: #337BD7;
  }
}

</style>